<style>
    .link-wrap {
        width: 800px;
        margin: 0 auto;
        margin-top: 100px;
    }

    .link-wrap h2 {
        font-size: 26px;
        text-align: center;
    }
</style>
<div class="sm-rightPanel">
    <div class="layui-anim layui-anim-upbit">
        <div class="link-wrap">
            <h2>微官网</h2>
            <p style="text-align: center;color:#FF5722;">
                <img id="url_img" style="width: 100%;max-width:200px;">
            </p>
            <div class="layui-form-item">
                <label class="layui-form-label">链接</label>
                <button class="layui-btn btn-copy" style="float: right" data-clipboard-action="copy"
                        data-clipboard-target="#websiteIndexUrl"><i class="icon-fuzhi iconfont"></i>复制
                </button>
                <div class="layui-input-block" style="margin-right: 100px;">
                    <input id="websiteIndexUrl" type="text" name="url" readonly="" placeholder="请输入url"
                           class="layui-input" value="/wxapi/gh_a37e6f06c1a9/message.html">
                </div>
            </div>
            <p style="text-align: center;color:#FF5722;margin-top: 10px;">
                微信扫描二维码分享或复制链接
            </p>
            <p style="text-align: center;color:#FF5722;margin-top: 10px;">
                分享前，请确认已完善企业信息！
            </p>
        </div>
    </div>
</div>

<script>

    layui.use(['layer', 'table', 'form'], function () {
        var layer = layui.layer;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.$;

        //表单重新渲染
        form.render();

        // $("#generate_website").click(function () {
        //     getWebsiteInfo();
        // });

        getWebsiteInfo();

        function getWebsiteInfo() {

            $.ajax({
                type: "GET",
                url: '/front/websiteindex/generate',
                success: function (result) {
                    if (result.success) {
                        $("#websiteIndexUrl").val(result.data.website_index_url);
                        $("#url_img").attr("src", result.data.picUrl);
                    } else {
                        layer.msg("操作异常");
                    }


                    smartAui.loadJs("/js/plugin/clipboard/clipboard.min.js", function () {
                        var clipboard = new ClipboardJS('.btn-copy');
                        clipboard.on('success', function (e) {
                            layer.msg("复制成功！");
                        });

                        clipboard.on('error', function (e) {
                            layer.msg("复制失败！");
                        });
                    });
                },
            })
        }

    });


</script>